package org.test.client.ui.content.uifeature;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import org.test.client.listener.ToolTipMouseListener;
import org.test.client.ui.component.panel.TitlePanePanel;
import org.test.client.ui.component.window.PopupWindow;
import org.test.client.ui.skinui.btn.MyButtonUI;

public class PopUpInfoPanel extends TitlePanePanel implements ActionListener{ 

	PopupWindow info = PopupWindow.getInstance
			("这是一个测试信息,测试popwindow 显示程度,请合理使用." , PopupWindow.TYPE_INFO);
	PopupWindow warning = PopupWindow.getInstance
			("这是一个测试信息,测试popwindow 显示程度,请合理使用." , PopupWindow.TYPE_WARNING);
	PopupWindow success = PopupWindow.getInstance
			("这是一个测试信息,测试popwindow 显示程度,请合理使用." , PopupWindow.TYPE_SUCCESS);
	PopupWindow white = PopupWindow.getInstance
			("这是一个测试信息,测试popwindow 显示程度,请合理使用." , PopupWindow.TYPE_WHITE);
	
	
	public PopupWindow[] windows = new PopupWindow[]{info,success,warning,white};
	JButton btn1 = new JButton("按钮");
	JButton btn2 = new JButton("鼠标Click");
	JButton btn3 = new JButton("鼠标Click");
	JButton btn4 = new JButton("鼠标Click");
	JButton btn5 = new JButton("鼠标Click");
	
	public PopUpInfoPanel() {
		super("Popup info", null);
		doInit();
	}
	
	@Override
	public TitlePanePanel doInit() {
		super.doInit();
		
		
		btn2.setUI(MyButtonUI.createInfoBtnUI(btn2));
		btn3.setUI(MyButtonUI.createSuccessBtnUI(btn3));
		btn4.setUI(MyButtonUI.createWarningBtnUI(btn4));
		btn5.setUI(MyButtonUI.createWhiteBtnUI(btn5));
		
		btn2.addActionListener(this);
		btn3.addActionListener(this);
		btn4.addActionListener(this);
		btn5.addActionListener(this);
		
		btn2.setActionCommand("0");
		btn3.setActionCommand("1");
		btn4.setActionCommand("2");
		btn5.setActionCommand("3");
		
		this.add(btn1);
		this.add(btn2);
		this.add(btn3);
		this.add(btn4);
		this.add(btn5);
		
//		this.setPreferredSize(new Dimension(0,100));
		
		return this;
	}

	@Override
	public void actionPerformed(ActionEvent ac) {
		String cmd = ac.getActionCommand();
		int index = Integer.parseInt(cmd);
		
		windows[index].setVisible(true);
	}
	
	
}
